<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <link rel="shortcut icon" href="<!--{eval echo register_static('img/touch-icon-57x57.png');}-->">

        <title>粉粉管理系统</title>

        <!-- Bootstrap core CSS -->
        <link href="<!--{eval echo register_static('css/bootstrap.min.css');}-->" rel="stylesheet">
        <link href="<!--{eval echo register_static('css/bootstrap-reset.css');}-->" rel="stylesheet">

        <!--Animation css-->
        <link href="<!--{eval echo register_static('css/animate.css');}-->" rel="stylesheet">

        <!--Icon-fonts css-->
        <link href="<!--{eval echo register_static('assets/font-awesome/css/font-awesome.css');}-->" rel="stylesheet" />
        <link href="<!--{eval echo register_static('assets/ionicon/css/ionicons.min.css');}-->" rel="stylesheet" />
        
        <link href="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.css');}-->" rel="stylesheet">
        
        <!-- Plugins css -->
        <link href="<!--{eval echo register_static('assets/modal-effect/css/component.css');}-->" rel="stylesheet">

        <!-- DataTables -->
        <link rel="stylesheet" href="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.css" rel="stylesheet');}-->" />

        <!-- Custom styles for this template -->
        <link href="<!--{eval echo register_static('css/style.css');}-->" rel="stylesheet">
        <link href="<!--{eval echo register_static('css/helper.css');}-->" rel="stylesheet">
        
        <!-- My styles for this template -->
        <link href="<!--{eval echo register_static('css/common.css');}-->" rel="stylesheet">

    </head>

    <body>

        <!-- Aside Start-->
        <!--{template admin_v2/leftside}-->
        <!-- Aside Ends-->


        <!--Main Content Start -->
        <section class="content">
            
            <!-- Header -->
            <!--{template admin_v2/header}-->
            <!-- Header Ends -->


            <!-- Page Content Start -->
            <!-- ================== -->

            <div class="wraper container-fluid diary-topics">
            
            	<div class="row">
                    <div class="col-md-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">全站公告列表</h3>                                
                            </div> 
                            <br/>
                            <button class="btn btn-primary"  data-toggle="modal" data-target=".bs-example-modal-lg">发布公告</button>                                 
                            <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" style="display: none;">
                                    <div class="modal-dialog modal-lg">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                                            	<h4 class="modal-title" id="myLargeModalLabel">发布公告</h4>
                                            </div>
                                          
                                            <div class="modal-body">
                                             	<div class="row">
                                             		<div class="col-md-7">
                                             			<div class=" form">
						                                    <form class="cmxform form-horizontal tasi-form" id="commentForm" method="POST"  novalidate="novalidate">
						                                        <div class="form-group ">
						                                            <label for="cname" class="control-label col-lg-2">公告标题</label>
						                                            <div class="col-lg-10">
						                                                <input class=" form-control" id="msg_title" name="title" type="text" placeholder="15个字符以内" required="" aria-required="true">
						                                            </div>
						                                        </div>
						                                        <div class="form-group ">
						                                            <label for="cemail" class="control-label col-lg-2">跳转链接</label>
						                                            <div class="col-lg-10">
						                                                <input class="form-control " id="msg_ac"   name="action"  type="text" placeholder="http://或者'pinksns://开头"  required="" aria-required="true">
						                                            </div>
						                                        </div>
						                                        <div class="form-group ">
						                                            <label for="curl" class="control-label col-lg-2">图片链接</label>
						                                            <div class="col-lg-10">
						                                                <input class="form-control " id='msg_pic'  name="picture" type="text" placeholder="http://">
						                                            </div>
						                                        </div>
						                                        <div class="form-group ">
						                                            <label for="ccomment" class="control-label col-lg-2">通知内容</label>
						                                            <div class="col-lg-10">
						                                                <textarea class="form-control " id="msg_con"  name="content" placeholder="250个字符以内" required="" aria-required="true"></textarea>
						                                            </div>
						                                        </div>
						                                        <div class="form-group">
						                                            <div class="col-lg-offset-2 col-lg-10">
						                            					<button class="btn btn-primary" id="releaseTest" type="button">发布测试</button>
						                                                <button class="btn btn-default" id="previewMessage" type="button">预览</button>
						                                                 
						                                            </div>
						                                        </div>
						                                    </form>
														</div> 
                                             		</div>
                                             		<div class="col-md-5">
                                             			<div class="row">
                                             				<div class="col-md-12">
                                             					<span id="one_title"></span>
                                             				</div>
                                             			</div>
                                             			<div class="row">
                                             				<div class="col-md-12">
                                             				<span id="two_content"></span>
                                             				</div>
                                             			</div>
                                             			<div class="row">
                                             				<div class="col-md-12">
                                             				<span id="three_pic"></span>
                                             				</div>
                                             			</div>
                                             			<div class="row">
                                             				<div class="col-md-12">
                                             				<span id="four_url"></span>
                                             				</div>
                                             			</div>
                                             		</div>
                                             	</div>
                                            </div>
                                        </div><!-- /.modal-content -->
                                    </div><!-- /.modal-dialog -->
                            </div><!-- /.modal -->                   		                        
                            <div class="panel-body">
                       	
                                <div class="row">
                                    <div class="col-md-12 col-sm-12 col-xs-12">
                                        <table id="datatable" class="table table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                     <th>标题</th>                                         
                           							 <th>内容</th>                                         
                            						 <th>跳转action</th>
                            						 <th>图片</th>  
                            						 <th width="5%">状态</th>                  
                          							 <th width="20%">操作</th>       
                                                </tr>
                                            </thead>

                                            <tbody>
                                            <!--{if !empty($list) }-->
						                        <!--{loop $list $value}-->
						                      		<tr id="tr_{$value[feed_id]}">
						                      		<td>{$value[data][title]}</td>
						                      		<td><!--{$value[data][content]}--></td>
						                      		<td><!--{$value[data][action]}--></td>
						                      		<td>
						                      		<!--{if $value[data][image]}-->
						                      			<img src="{$value[data][image][0]}" style="width:150px;height:100px;" />
						                      		<!--{/if}-->
						                      		</td>
						                      		<td>
						                      			 <!--{if isset($value[test]) && $value[test]==1}-->
						                      			<span class="label label-warning">未上线</span>
						                      			  <!--{else}-->
						                      			 <span class="label label-success">已上线</span>                 			
						                      			  <!--{/if}-->
						                      		</td>
						                      		<td>
						                      		
						                      		 <!--{if isset($value[test]) && $value[test]==1}-->					                      		 
						                      		 	<button class="btn delete_announce btn-warning" data-feedid={$value[feed_id]} data-test={$value[test]}>删除</button>
						                      		 	<button class="btn btn-primary setOnline" data-feedid={$value[feed_id]}>上线</button>
						                      		 <!--{else}-->
						                      		    <button class="btn delete_announce btn-warning" data-feedid={$value[feed_id]} data-test={$value[test]}>删除</button>
						                      		
						                      		 <!--{/if}-->
						                      		</td>
						                      		</tr>
						                        <!--{/loop}-->
						                    <!--{/if}-->
                                           
                                             </tbody>
                                         </table>
                                         <!--{if $pageUrl}-->
		                                 <ul class="pager"> 
		                                    <li> 
		                                        <a href="{$pageUrl['prev']}"> <i class="fa fa-angle-double-left"></i>上一页</a> 
		                                    </li> 
		                                    <li> 
		                                        <a href="{$pageUrl['first']}"> <i class="fa"></i>第一页</a> 
		                                    </li> 
		                                    <li> 
		                                        <a href="{$pageUrl['next']}">下一页 <i class="fa fa-angle-double-right"></i> </a> 
		                                    </li> 
		                                 </ul>
		                                 <!--{/if}--> 
                                     </div>
                                 </div>
                             </div>
                         </div>
                     </div>
                 </div>

            </div>
            <!-- Page Content Ends -->
            <!-- ================== -->
            
            <div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
      
  			</div><!-- /.modal -->
            

            <!-- Footer Start -->
            <!--{template admin_v2/footer}-->
            <!-- Footer Ends -->



        </section>
        <!-- Main Content Ends -->


        <!-- js placed at the end of the document so the pages load faster -->
        <script src="<!--{eval echo register_static('js/jquery.js');}-->"></script>
        <script src="<!--{eval echo register_static('js/bootstrap.min.js');}-->"></script>
        <script src="<!--{eval echo register_static('js/pace.min.js');}-->"></script>
        <script src="<!--{eval echo register_static('js/wow.min.js');}-->"></script>
        <script src="<!--{eval echo register_static('js/jquery.nicescroll.js');}-->" type="text/javascript"></script>

		<script src="<!--{eval echo register_static('js/jquery.app.js');}-->"></script>

        <script src="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.js');}-->"></script>
        <script src="<!--{eval echo register_static('assets/datatables/dataTables.bootstrap.js');}-->"></script>
		<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.init.js');}-->"></script>
        <script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.js');}-->"></script>

        
        <!-- Modal-Effect -->
        <script src="<!--{eval echo register_static('assets/modal-effect/js/classie.js');}-->"></script>
        <script src="<!--{eval echo register_static('assets/modal-effect/js/modalEffects.js');}-->"></script>
        
		<script type="text/javascript">
			$(function(){
				$(document).on('click','.setOnline',function(){
					var feedid = $(this).data('feedid');
					swal(
	                		{   
		                		title: "确定上线",
		                		text: "上线公告可删除，也请慎重！",
		                		type: "warning",   
		                		showCancelButton: true,   
		                		confirmButtonColor: "#DD6B55",   
		                		confirmButtonText: "Sure!",   
		                		closeOnConfirm: false 
	                		}, 
	                		function(){
	                			$.ajax(
	                		            {
	                		                url     :   "admin.php?ac=sendAnnounce_class&op=setAnnouceOnLine",
	                		                type    :   "GET",
	                		                data    :   {'online':1},
	                		                success :   function(data)
	                		                            {
	                		                				if (data == 1) {
	                		                					 $("#tr_"+feedid).fadeOut();	
	                		                					swal("上线成功!", "公告已经上线！", "success");
	                		                				}else{
	                		                					swal("上线失败!", "发生了神马！", "error"); 
	                		                				}
	                		                				refresh();
	                		                            }
	                		            });
	                });
				});
				$(document).on('click','.delete_announce',function(){
					var feedid = $(this).data('feedid');
					if($(this).data('test') == undefined){
						test = 0;
					}else{
						test = $(this).data('test') ;
					}
					swal(
	                		{   
		                		title: "确定删除?",
		                		text: "删除的公告不可恢复，慎重操作!",
		                		type: "warning",   
		                		showCancelButton: true,   
		                		confirmButtonColor: "#DD6B55",   
		                		confirmButtonText: "Sure!",   
		                		closeOnConfirm: false 
	                		}, 
	                		function(){
	                			$.ajax(
	                		            {
	                		                url     :   "admin.php?ac=sendAnnounce_class&op=removeAnnounce",
	                		                type    :   "POST",
	                		                data    :   {'id':feedid,'test':test},
	                		                success :   function(data)
	                		                            {
	                		                				if (data == 1) {
	                		                					 $("#tr_"+feedid).fadeOut();	
	                		                					swal("删除成功!", "公告已经被删除！", "success");
	                		                				}else{
	                		                					swal("删除失败!", "发生了神马！", "error"); 
	                		                				}
	                		                				refresh();
	                		                            }
	                		            });
	                });
	 			
				});
				
				 title 		= '';
		         content	= '';
		         picurl		= '';
		         action		= '';
		         $('#msg_title').blur(function(){
		        	 title ='';
		        	 title = $(this).val();    	
		         })
		          $('#msg_con').blur(function(){
		        	  content = '';
		        	  content = $(this).val();
		         })
		           $('#msg_pic').blur(function(){
		        	   picurl = '';
		        	   picurl = $(this).val();
		         })
		           $('#msg_ac').blur(function(){
		        	   action = '';
		        	   action = $(this).val();
		         })
		         $('#previewMessage').click(function(){
		        	 $('#one_title').empty()
		        	 $('#two_content').empty()
		        	 $('#three_url').empty()
		        	
		        	 $('#one_title').html('<strong>标题：</strong><h3>'+title+'</h3>')
		        	 if(content){
		        		 $('#two_content').css({"width":"80px","height":"50px"}).html('<p><strong>内容：</strong>'+content+'</p>');
		        	 }
		        	 if(picurl){
		        		 $('#three_pic').css({"width":"80px","height":"50px"}).html('<p><strong>图片：</strong><img style="width:270px;height:130px" src="'+picurl+'"/></p>')
		        	 }
		        	 if(action){
		        		 $('#four_url').html('<strong>跳转的链接：</strong><h5>'+action+'</h5>')
		        	 }
		         })		     
		         $('#releaseTest').click(function(){
		        	 swal(
		                		{   
			                		title: "确定发布测试?",
			                		text: "客户端在测试服务器可见！",
			                		type: "warning",   
			                		showCancelButton: true,   
			                		confirmButtonColor: "#DD6B55",   
			                		confirmButtonText: "Sure!",   
			                		closeOnConfirm: false 
		                		}, 
		                		function(){
		                			$.ajax(
		                		            {
		                		                url     :   "admin.php?ac=sendAnnounce_class&op=sendAnnounce",
		                		                type    :   "POST",
		                		                data    :   $('#commentForm').serialize(),
		                		                success :   function(data)
		                		                            {
		                		                				if (data == 1) {
		                		                					swal("发布成功!", "公告已经被成功发布！", "success");
		                		                				}else{
		                		                					swal("发布失败!", "检查一下发布的内容吧！", "error"); 
		                		                				}
		                		                				refresh();
		                		                            }
		                		            });
		                		});
		         })
		     	// 刷新当前页面
	        		function refresh(){
		        	 setTimeout(window.location.reload(),50000);
	        		}
						
			})
        </script>
    </body>
</html>
